namespace FlightTicketDb.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class sdfasdfas : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Airlines",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        AirlineName = c.String(nullable: false, maxLength: 20),
                        Url = c.String(nullable: false),
                        Domain = c.String(),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.AirlineAccounts",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        username = c.String(nullable: false, maxLength: 20),
                        pwd = c.String(nullable: false, maxLength: 20),
                        ArilineId = c.Long(nullable: false),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Airlines", t => t.ArilineId, cascadeDelete: true)
                .Index(t => t.ArilineId);
            
            CreateTable(
                "dbo.FlightTicketChildTasks",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        AirlineId = c.Long(nullable: false),
                        AirCode1 = c.String(maxLength: 3),
                        AirCode2 = c.String(maxLength: 3),
                        AirCode3 = c.String(maxLength: 3),
                        date1 = c.DateTime(nullable: false),
                        date2 = c.DateTime(),
                        AirLineType = c.Int(nullable: false),
                        FlightTicketTaskId = c.Long(nullable: false),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Airlines", t => t.AirlineId, cascadeDelete: true)
                .ForeignKey("dbo.FlightTicketTasks", t => t.FlightTicketTaskId, cascadeDelete: true)
                .Index(t => t.AirlineId)
                .Index(t => t.FlightTicketTaskId);
            
            CreateTable(
                "dbo.FlightTicketTasks",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        AirlineID = c.Int(nullable: false),
                        AirCode1 = c.String(maxLength: 3),
                        AirCode2 = c.String(maxLength: 3),
                        AirCode3 = c.String(maxLength: 3),
                        date1 = c.DateTime(),
                        date2 = c.DateTime(),
                        AirLineType = c.Int(nullable: false),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.AirlineCodes",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Code = c.String(nullable: false, maxLength: 3),
                        Name = c.String(),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.FlightTicketPrices",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        AirlineID = c.Int(nullable: false),
                        AirCode1 = c.String(maxLength: 3),
                        AirCode2 = c.String(maxLength: 3),
                        AirCode3 = c.String(maxLength: 3),
                        date1 = c.DateTime(nullable: false),
                        date2 = c.DateTime(nullable: false),
                        flightNumber = c.String(),
                        Cabin = c.String(),
                        Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                        PriceTime = c.DateTime(nullable: false),
                        AirLineType = c.Int(nullable: false),
                        Key = c.Guid(nullable: false),
                        CreateTime = c.DateTime(),
                        IsEnable = c.Boolean(nullable: false),
                        IsDelete = c.Byte(nullable: false),
                        UpdateTime = c.DateTime(),
                        DeleteTime = c.DateTime(),
                        SeqNo = c.Byte(nullable: false),
                        TaskStatus = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.FlightTicketChildTasks", "FlightTicketTaskId", "dbo.FlightTicketTasks");
            DropForeignKey("dbo.FlightTicketChildTasks", "AirlineId", "dbo.Airlines");
            DropForeignKey("dbo.AirlineAccounts", "ArilineId", "dbo.Airlines");
            DropIndex("dbo.FlightTicketChildTasks", new[] { "FlightTicketTaskId" });
            DropIndex("dbo.FlightTicketChildTasks", new[] { "AirlineId" });
            DropIndex("dbo.AirlineAccounts", new[] { "ArilineId" });
            DropTable("dbo.FlightTicketPrices");
            DropTable("dbo.AirlineCodes");
            DropTable("dbo.FlightTicketTasks");
            DropTable("dbo.FlightTicketChildTasks");
            DropTable("dbo.AirlineAccounts");
            DropTable("dbo.Airlines");
        }
    }
}
